<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/4
 * Time: 13:39
 */

namespace common\business\mdmtask;


use common\business\DbHandler;
use common\models\MdmTask;
use common\result\ActionResult;

class MdmTaskApiHandler  extends DbHandler
{
    /**
     * @param $obj MdmTask
     * @return ActionResult
     */
    public function createMdmTask($obj){
        return $this->create($obj);
    }

    /**
     * @param MdmTask $newObj
     * @param MdmTask $oldObj
     * @return ActionResult
     */
    public function updateMdmTask($newObj, $oldObj = null){
        if (!$oldObj){
            $oldObj = MdmTask::findOne([
                'id' => $newObj->id,
            ]);
        }
        return $this->update($newObj, $oldObj, [
            'input',
            'flag',
            'output',
            'started_at',
            'stopped_at',
        ]);
    }

    /**
     * @param $obj MdmTask
     * @return ActionResult
     */
    public function deleteMdmTask($obj){
        return $this->delete($obj);
    }
}